﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'ClienteGetList')
	BEGIN
		DROP  Procedure  ClienteGetList
	END
GO

CREATE PROCEDURE ClienteGetList 	
	(	
		@empresaId AS INT,		
		@id AS VARCHAR(12) = NULL,
		@filtro AS VARCHAR(50) = NULL		
	)	
AS
BEGIN	
	SET NOCOUNT ON
	
	SELECT Cliente_Id AS Id, Cliente_Nombre AS Nombre
	FROM Cliente
	WHERE Emp_Id = @empresaId	  
	  AND Cliente_Nombre like '%' + ISNULL(@filtro,'') + '%'
	  AND Cliente_Id = ISNULL(@Id, Cliente_Id)
	  AND Cliente_Activo = 'si' 
	ORDER BY Cliente_Nombre
	
	SET NOCOUNT OFF
END
GO
 